package mx.com.crowdgine.util.ResourceFinder;

import java.io.*;
import java.net.URL;

public class ResourceRetriever {
	public static URL getResource(final String filename) throws IOException{
		URL url = ClassLoader.getSystemResource(filename);
		
		if(url==null){
			return new URL("file","localhost",filename);
		}
		else {
			return url;
		}
	}
	
	public static InputStream getResourceAsStream(final String filename) throws IOException{
		InputStream is= ClassLoader.getSystemResourceAsStream(filename);
		
		if(is==null){
			return new FileInputStream(filename);
		}
		else{
			return is;
		}
	}
	
	public static BufferedReader getResourceAsBufferedReader(final String filename) throws IOException{
		File f = new File(filename);
		BufferedReader br = new BufferedReader(new FileReader(f));
		return br;
	}

}
